IdeaBlade DevForce 2010 Help Reference
StartParallel(Func<CoroutineOperation,IEnumerable<Func<INotifyCompleted>>>,Action<CoroutineOperation>) Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class > StartParallel Method : StartParallel(Func<CoroutineOperation,IEnumerable<Func<INotifyCompleted>>>,Action<CoroutineOperation>) Method



asyncFns
List of asynchronous functions
completedHandler
Optional completion handler
Start parallel exeuction of multiple asynchronous actions.

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function StartParallel( _
   ByVal asyncFns As Func(Of CoroutineOperation,IEnumerable(Of Func(Of INotifyCompleted))), _
   Optional ByVal completedHandler As Action(Of CoroutineOperation) _
) As CoroutineOperation
Visual Basic (Usage)Copy Code
Dim asyncFns As Func(Of CoroutineOperation,IEnumerable(Of Func(Of INotifyCompleted)))
Dim completedHandler As Action(Of CoroutineOperation)
Dim value As CoroutineOperation
 
value = Coroutine.StartParallel(asyncFns, completedHandler)

Parameters

asyncFns
List of asynchronous functions
completedHandler
Optional completion handler

Return Value

A CoroutineOperation representing this operation

Example

C#Copy Code
public void CoroutineSampleParallel() {

   // Start some parallel async operations.
   var op = Coroutine.StartParallel(SampleActions);

   // Listen for completion. 
   op.Completed += (s, e) => {
     MessageBox.Show(e.Notifications.Count.ToString() + " operations completed");
     // You can loop thru notifications for results from each operation.
   };
 }

 // A block of asynchronous actions to be performed in parallel.
 private IEnumerable<INotifyCompleted> SampleActions() {

   // Start a query for all customers in specified country.
   yield return _entityManager.Customers.Where(c => c.Country == "UK").ExecuteAsync();

   // Start another query for all employees.  This will run in parallel.
   yield return _entityManager.Employees.ExecuteAsync();
 }              
   
/***************************************************************************************/
// Sample 2 - passing arguments to an iterator    
   
 public void CoroutineSampleParallel2() {

   // Start some parallel async operations.
   var op = Coroutine.StartParallel(() => SampleActions2("UK"));

   // Listen for completion. 
   op.Completed += (s, e) => {
     MessageBox.Show(e.Notifications.Count.ToString() + " operations completed");
     // You can loop thru notifications for results from each operation.
   };
 }

 // A block of asynchronous actions to be performed in parallel.
 private IEnumerable<INotifyCompleted> SampleActions2(string country) {

   // Start a query for all customers in specified country.
   yield return _em1.Customers.Where(c => c.Country == country).ExecuteAsync();

   // Start another query for all employeesin specified country. This will run in parallel.
   yield return _em1.Employees.Where(e=> e.Country == country).ExecuteAsync();
 }

Remarks

Used to start parallel execution of the asynchronous actions within a list of asynchronous functions. Each asychronous action is started on its own thread. Once all actions have completed, the completion handler is called. The CoroutineOperation.Notifications can be used to check the results of each action.

Use this overload of the StartParallel method when your iterator accepts a CoroutineOperation as an argument.

This overload of the StartParallel method is useful in Visual Basic, where iterators are not supported.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.